<template>
  <div class="deil">
    <p>{{newobj.title}}</p>
    <p>{{newobj.context}}</p>
    <p>{{newobj.money}}</p>

    <button @click="gwc(newobj)">
        加入购物车
    </button>
  </div>
</template>

<script>
import {mapActions} from "vuex"
export default {
  data() {
    return {
      id: null,
      newobj: {}
    };
  },
  created() {
    console.log(this.$route.params.id);
    
    this.id = this.$route.params.id;
    this.xqlists(this.id);
  },
  methods: {
      ...mapActions(["ADD"]),
    xqlists(id) {
      this.$api.shopDeil(id).then(res => {
        if (res.code === 1) {
          this.newobj = res.data.data[0];
        }
      });
    },
    //加入购物车
    gwc(item){
        this.ADD(item)
        this.$router.push("/tree")
    }
  }
};
</script>

<style>
</style>